package com.xjscrm.console.web.operatePlan;

import com.xjscrm.console.param.operatePlan.*;
import com.xjscrm.console.service.customer.operatePlan.GroupPullBatchService;
import com.xjscrm.console.service.customer.operatePlan.GroupPullService;
import com.xjscrm.console.vo.EffectuateGroupVo;
import com.xjscrm.console.vo.GroupPullConfigDeviceVo;
import com.xjscrm.console.vo.GroupPullVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(value = "标签拉群方案管理", tags = "标签拉群方案管理")
@RestController
@RequestMapping(value = "/tagPlan")
public class GroupPullTagController {

    @Autowired
    private GroupPullService groupPullService;

    @Autowired
    private GroupPullBatchService groupPullBatchService;

    @ApiOperation(value = "新增标签拉群方案", notes = "新增标签拉群方案", response = Long.class)
    @PostMapping(value = "/addGroupPullTagPlan")
    public Object addGroupPullTagPlan(@RequestBody GroupPullDto groupPullDto)throws Exception{
        return   groupPullService.addGroupPullPlan(groupPullDto);
    }


    @ApiOperation(value = "获取标签拉群方案列表", notes = "获取标签拉群方案列表", response = GroupPullVo.class)
    @PostMapping(value = "/getGroupPullTagPlanList")
    public Object getGroupPullTagPlanList(@RequestBody GroupPullQuery groupPullQuery)throws Exception{
        return   groupPullService.getGroupPullPlanList(groupPullQuery);
    }

    @ApiOperation(value = "获取标签拉群方案详情", notes = "获取标签拉群方案详情", response = GroupPullVo.class)
    @PostMapping(value = "/getGroupPullTagPlanDetail")
    public Object getGroupPullTagPlanDetail(@RequestBody GroupPullDto groupPullDto)throws Exception{
        return   groupPullService.getGroupPullPlanDetail(groupPullDto);
    }


    @ApiOperation(value = "修改标签拉群方案", notes = "修改标签拉群方案", response = Boolean.class)
    @PostMapping(value = "/updateGroupPullTagPlan")
    public Object updateGroupPullTagPlan(@RequestBody GroupPullDto groupPullDto)throws Exception{
        groupPullService.updateGroupPullPlan(groupPullDto);
        return true;
    }
    @ApiOperation(value = "删除标签拉群方案", notes = "删除标签拉群方案", response = Boolean.class)
    @PostMapping(value = "/delGroupPullTagPlan")
    public Object delGroupPullTagPlan(@RequestBody GroupPullDto groupPullDto)throws Exception{
        groupPullService.delGroupPullPlan(groupPullDto);
        return true;
    }


    @ApiOperation(value = "批量新增标签拉群方案和机器人关系", notes = "批量新增标签拉群方案和机器人关系", response = Boolean.class)
    @PostMapping(value = "/batchAddPlanDevice")
    public Object batchAddPlanDevice(@RequestBody BatchAddGroupPullPlanDeviceDto batchAddGroupPullPlanDeviceDto)throws Exception{
        groupPullBatchService.batchAddPlanDevice(batchAddGroupPullPlanDeviceDto);
        return true;
    }

    @ApiOperation(value = "批量删除标签拉群方案和机器人关系", notes = "批量删除标签拉群方案和机器人关系", response = Boolean.class)
    @PostMapping(value = "/batchDelPlanDevice")
    public Object batchDelPlanDevice(@RequestBody BatchAddGroupPullPlanDeviceDto batchAddGroupPullPlanDeviceDto)throws Exception{
        groupPullBatchService.batchDelPlanDevice(batchAddGroupPullPlanDeviceDto);
        return true;
    }


    @ApiOperation(value = "批量设置休眠设置", notes = "批量设置休眠设置", response = Boolean.class)
    @PostMapping(value = "/batchUpdatePlanDevice")
    public Object batchUpdatePlanDevice(@RequestBody BatchAddGroupPullPlanDeviceDto batchAddGroupPullPlanDeviceDto)throws Exception{
        groupPullBatchService.batchUpdatePlanDevice(batchAddGroupPullPlanDeviceDto);
        return true;
    }


    @ApiOperation(value = "获取方案应用列表", notes = "获取方案应用列表", response = GroupPullConfigDeviceVo.class)
    @PostMapping(value = "/getDelPlanDeviceList")
    public Object getDelPlanDeviceList(@RequestBody GroupPullDeviceQuery GroupPullDeviceQuery)throws Exception{
        return groupPullService.getDelPlanDeviceList(GroupPullDeviceQuery);
    }


    @ApiOperation(value = "获取生效群", notes = "获取生效群", response = EffectuateGroupVo.class)
    @PostMapping("/getEffectuateGroup")
    public Object getEffectuateGroup(@RequestBody EffectuateGroupDto effectuateGroupDto)throws Exception{
        return groupPullService.findAddFangetEffectuateGroupGroup(effectuateGroupDto);
    }


    @ApiOperation(value = "查询标签拉群应用的机器人ID列表", notes = "查询标签拉群应用的机器人ID列表", response = Long.class)
    @PostMapping(value = "/getUsedDeviceUniqueIds")
    public Object getUsedDeviceUniqueIds(@RequestBody GroupPullDto groupPullDto)throws Exception{
        return groupPullService.getUsedDeviceUniqueIds(groupPullDto);
    }
}
